package com.waves.user.listener;

import com.rabbitmq.client.Channel;
import com.waves.core.constant.MQConstant;
import com.waves.core.domain.dto.ScanSuccessMessageDTO;
import com.waves.websocket.service.WebSocketService;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * @author dlw
 * @email
 */
@Service
public class UserScanListener {

    @Resource
    private WebSocketService webSocketService;

    /**
     * 通知用户扫码成功
     * @param message
     * @param channel
     * @param msg
     * @throws IOException
     */
    @RabbitListener(queues = MQConstant.SCAN_MSG_QUEUE)
    public void listener(ScanSuccessMessageDTO message, Channel channel, Message msg) throws IOException {
        webSocketService.scanSuccess(message.getCode());
    }


}
